package cn.bugDance.domain.strategy.service.dispatch;

import cn.bugDance.domain.strategy.repository.IStrategyRepository;
import cn.bugDance.domain.strategy.service.algorithm.IAlgorithm;
import cn.bugDance.types.common.Constants;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.security.SecureRandom;

@Service
public class RaffleStrategyDispatch implements IRaffleStrategyDispatch{

    @Resource
    private ApplicationContext applicationContext;

    @Value("${app.strategy.algorithm}")
    private String algorithmName;

    @Override
    public Integer randomRaffle(Long strategyId) {
        return applicationContext.getBean(algorithmName, IAlgorithm.class).algorithmQuery(strategyId);
    }

    @Override
    public Integer randomRaffle(Long strategyId, Integer level) {
       return applicationContext.getBean(algorithmName, IAlgorithm.class).algorithmQuery(strategyId, level);
    }
}
